package org.dyz.banana.platform.uaa.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.dyz.banana.platform.common.vo.HttpResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Api(value = "测试控制器")
@RestController
public class TestController {

    @ApiOperation(value = "测试方法", notes = "")
    @PostMapping(value = "/test")
    public HttpResult test(
            @ApiParam(value = "测试入参" , required=true )
            @RequestBody String test, HttpServletRequest request) throws IOException {
        StringBuilder builder = new StringBuilder();
        for(int i=0;i<request.getCookies().length;i++){
            Cookie cookie = request.getCookies()[i];
            builder.append(cookie.getName()).append(" | ");
        }
        return HttpResult.ok(builder.toString());
    }
}
